/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "QLTTB_VARIAVEL")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Variavel.findAll", query = "SELECT v FROM Variavel v"),
    @NamedQuery(name = "Variavel.findByVarId", query = "SELECT v FROM Variavel v WHERE v.varId = :varId"),
    @NamedQuery(name = "Variavel.findByVarNm", query = "SELECT v FROM Variavel v WHERE v.varNm = :varNm"),
    @NamedQuery(name = "Variavel.findByVarDs", query = "SELECT v FROM Variavel v WHERE v.varDs = :varDs"),
    @NamedQuery(name = "Variavel.findByVarIcMostraMedia", query = "SELECT v FROM Variavel v WHERE v.varIcMostraMedia = :varIcMostraMedia"),
    @NamedQuery(name = "Variavel.findByVarIcMostraMin", query = "SELECT v FROM Variavel v WHERE v.varIcMostraMin = :varIcMostraMin"),
    @NamedQuery(name = "Variavel.findByVarIcMostraQuantOcorr", query = "SELECT v FROM Variavel v WHERE v.varIcMostraQuantOcorr = :varIcMostraQuantOcorr"),
    @NamedQuery(name = "Variavel.findByVarIcMostraTotal", query = "SELECT v FROM Variavel v WHERE v.varIcMostraTotal = :varIcMostraTotal"),
    @NamedQuery(name = "Variavel.findByVarIcMostraMax", query = "SELECT v FROM Variavel v WHERE v.varIcMostraMax = :varIcMostraMax"),
    @NamedQuery(name = "Variavel.findByVarIcMostraCodflu", query = "SELECT v FROM Variavel v WHERE v.varIcMostraCodflu = :varIcMostraCodflu")})
public class Variavel implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "VAR_ID")
    private BigDecimal varId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 104)
    @Column(name = "VAR_NM")
    private String varNm;
    @Size(max = 4000)
    @Column(name = "VAR_DS")
    private String varDs;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VAR_IC_MOSTRA_MEDIA")
    private short varIcMostraMedia;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VAR_IC_MOSTRA_MIN")
    private short varIcMostraMin;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VAR_IC_MOSTRA_QUANT_OCORR")
    private short varIcMostraQuantOcorr;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VAR_IC_MOSTRA_TOTAL")
    private short varIcMostraTotal;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VAR_IC_MOSTRA_MAX")
    private short varIcMostraMax;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VAR_IC_MOSTRA_CODFLU")
    private short varIcMostraCodflu;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cvhVarId")
    private List<CaracterizacaoVhm> caracterizacaoVhmList;
    @OneToMany(mappedBy = "mtoVarId")
    private List<MetodoObtencao> metodoObtencaoList;
    @JoinColumn(name = "VAR_TPG_ID", referencedColumnName = "TPG_ID")
    @ManyToOne
    private TipoGrafico varTpgId;
    @JoinColumn(name = "VAR_GPV_ID", referencedColumnName = "GPV_ID")
    @ManyToOne(optional = false)
    private GrupoVariavel varGpvId;

    public Variavel() {
    }

    public Variavel(BigDecimal varId) {
        this.varId = varId;
    }

    public Variavel(BigDecimal varId, String varNm, short varIcMostraMedia, short varIcMostraMin, short varIcMostraQuantOcorr, short varIcMostraTotal, short varIcMostraMax, short varIcMostraCodflu) {
        this.varId = varId;
        this.varNm = varNm;
        this.varIcMostraMedia = varIcMostraMedia;
        this.varIcMostraMin = varIcMostraMin;
        this.varIcMostraQuantOcorr = varIcMostraQuantOcorr;
        this.varIcMostraTotal = varIcMostraTotal;
        this.varIcMostraMax = varIcMostraMax;
        this.varIcMostraCodflu = varIcMostraCodflu;
    }

    public BigDecimal getVarId() {
        return varId;
    }

    public void setVarId(BigDecimal varId) {
        this.varId = varId;
    }

    public String getVarNm() {
        return varNm;
    }

    public void setVarNm(String varNm) {
        this.varNm = varNm;
    }

    public String getVarDs() {
        return varDs;
    }

    public void setVarDs(String varDs) {
        this.varDs = varDs;
    }

    public short getVarIcMostraMedia() {
        return varIcMostraMedia;
    }

    public void setVarIcMostraMedia(short varIcMostraMedia) {
        this.varIcMostraMedia = varIcMostraMedia;
    }

    public short getVarIcMostraMin() {
        return varIcMostraMin;
    }

    public void setVarIcMostraMin(short varIcMostraMin) {
        this.varIcMostraMin = varIcMostraMin;
    }

    public short getVarIcMostraQuantOcorr() {
        return varIcMostraQuantOcorr;
    }

    public void setVarIcMostraQuantOcorr(short varIcMostraQuantOcorr) {
        this.varIcMostraQuantOcorr = varIcMostraQuantOcorr;
    }

    public short getVarIcMostraTotal() {
        return varIcMostraTotal;
    }

    public void setVarIcMostraTotal(short varIcMostraTotal) {
        this.varIcMostraTotal = varIcMostraTotal;
    }

    public short getVarIcMostraMax() {
        return varIcMostraMax;
    }

    public void setVarIcMostraMax(short varIcMostraMax) {
        this.varIcMostraMax = varIcMostraMax;
    }

    public short getVarIcMostraCodflu() {
        return varIcMostraCodflu;
    }

    public void setVarIcMostraCodflu(short varIcMostraCodflu) {
        this.varIcMostraCodflu = varIcMostraCodflu;
    }

    @XmlTransient
    public List<CaracterizacaoVhm> getCaracterizacaoVhmList() {
        return caracterizacaoVhmList;
    }

    public void setCaracterizacaoVhmList(List<CaracterizacaoVhm> caracterizacaoVhmList) {
        this.caracterizacaoVhmList = caracterizacaoVhmList;
    }

    @XmlTransient
    public List<MetodoObtencao> getMetodoObtencaoList() {
        return metodoObtencaoList;
    }

    public void setMetodoObtencaoList(List<MetodoObtencao> metodoObtencaoList) {
        this.metodoObtencaoList = metodoObtencaoList;
    }

    public TipoGrafico getVarTpgId() {
        return varTpgId;
    }

    public void setVarTpgId(TipoGrafico varTpgId) {
        this.varTpgId = varTpgId;
    }

    public GrupoVariavel getVarGpvId() {
        return varGpvId;
    }

    public void setVarGpvId(GrupoVariavel varGpvId) {
        this.varGpvId = varGpvId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (varId != null ? varId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Variavel)) {
            return false;
        }
        Variavel other = (Variavel) object;
        if ((this.varId == null && other.varId != null) || (this.varId != null && !this.varId.equals(other.varId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.gov.ana.service.Variavel[ varId=" + varId + " ]";
    }
    
}
